<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath }"></c:set>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>合力思腾-IT运维管理系统-CMDB-资产管理-配置维护-添加策略</title>
	
<link href="${path}/css/style.css" rel="stylesheet" type="text/css">
	<link href="${path}/common/plugins/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css">
<!--内部样式引用-->
<link rel="stylesheet" type="text/css" href="${path}/hhm/strategy/css/in-side.css" />
<!--基本支持性脚本-->
    <link href="${path }/common/plugins/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css">
    <link href="${path }/common/plugins/MyDate97/skin/WdatePicker.css" rel="stylesheet" type="text/css">
    <script src="${path }/js/jquery-1.7.2.min.js" type="text/javascript"></script>
	<script src="${path }/common/plugins/MyDate97/WdatePicker.js"></script>
    <script src="${path }/common/plugins/bootstrap/js/bootstrap.js"></script>
    <script src="${path }/common/plugins/zTree/jquery.ztree.core-3.5.min.js"></script>
    <script src="${path }/common/plugins/zTree/jquery.ztree.excheck-3.5.min.js"></script>
    <script src="${path }/common/plugins/layer/layer.js"></script>
    <script src="${path }/js/user_js.js"></script>
    <script src="${path}/js/common.js" type="text/javascript"></script>
    <link href='${path }/hhm/strategy/js/checkCalendar/fullcalendar.css' rel='stylesheet' />
	<link href='${path }/hhm/strategy/js/checkCalendar/fullcalendar.print.css' rel='stylesheet' media='print' />
	<script src='${path }/hhm/strategy/js/checkCalendar/lib/moment.min.js'></script>
	<script src='${path }/hhm/strategy/js/checkCalendar/fullcalendar.js'></script>
	<script src='${path }/hhm/strategy/js/checkCalendar/lang-all.js'></script>
	<script src='${path }/hhm/strategy/js/checkCalendar/checkCalendar.js'></script>
<!--弹窗-->


<style type="text/css">
	.form-horizontal .control-label{width:20%;}
	.form-horizontal .controls{margin-left:20%;}
	.form-actions{position:fixed;bottom:0px;left:0px;right:0px;padding:2px 8px;}
	.redTip{border-color:red!important;}
</style>
</head>
<body style="overflow:hidden;">
       <div class="row-fluid form-horizontal">
					<div class="well">
						<div class="control-group">
							<div class="span10">
								<label class="control-label">策略名称:</label>
								<div class="controls">
									<input class="span10" type="text" id="strategyName" onblur="checkNameNotNull(this)"/>
									<span style="color:red;">*</span>
								</div>
							</div>
						</div>
						<div class="control-group">
							<div class="span10">
								<label class="control-label">类型:</label>
								<div class="controls">
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="perf" checked="checked"/>
										性能
									</label>
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="config"/>
										配置
									</label>
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="capac"/>
										容量
									</label>
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="service"/>
										服务
									</label>
								</div>
								<br/>
								<div class="controls">
									
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="process"/>
										进程
									</label>
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="state"/>
										状态
									</label>
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="temp"/>
										温度
									</label>
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="mysql"/>
										MySql
									</label>
									<label class="radio inline">
										<input type="radio" name="aRadio" class="styled" value="oracle"/>
										Oracle
									</label>
								</div>
							</div>
						</div>
					</div>
		</div>
		<div class="form-actions align-right">
				<span style="color:red" id="saveflag"></span>
				<button type="button" id="saveBtn" onclick="saveStrategy();" class="btn btn-primary btn-mini">保存</button>
				<button type="button" onclick="closeWindow();" class="btn btn-mini">关闭</button>
				
		</div>
<script type="text/javascript">
	function saveStrategy(){
		var name = $("#strategyName").val();
		var typestr = $('input:radio:checked').val();
		$("#strategyName").blur();
		if($(".redTip").length==0){
			$.ajax({
				url:"${path }/radar/strategy/savestategy.do",				
				type: "POST",
				dataType:'json',
				data:{
					"name":name,
					"type":typestr
					},
				beforeSend:function(){
					$("#saveBtn").attr("disabled","disabled");
					$("#saveflag").html("正在保存中，请稍后......");
				},
				success:function(data){
					if(data.errorMessage == ""){
						var collectorStrategy = data.data;
						layer.msg('保存成功！', {icon : 1});
						var strategyName = $("#strategyName").val();
						var strategyType = $("input:radio:checked").val();
						parent.addStrategy(collectorStrategy.collectorStrategyId,strategyName,strategyType);
						parent.clean("plan");
						parent.clean("equipment");
						var index = parent.layer.getFrameIndex(window.name);
						setTimeout("parent.layer.close("+index+");",1000);
					}else{
						layer.msg('保存失败！', {icon : 1});
						$("#saveBtn").removeAttr("disabled");
					}
				}
			}); 
		}else{
			$.dialog({
				title:false,
				icon:"warning",
				content:'策略名称不能为空！',
				time:2
			});
		}
		
	}
	//=================================校验策略名称不为空=====================================
	function checkNameNotNull(field){
		if($.trim($(field).val())==""){
			$(field).addClass("redTip");
			$(field).attr("title","策略名称不能为空");
		}else{
			$(field).removeClass("redTip");
			$(field).attr("title","");
		}
	}
	function closeWindow(){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	}
</script>
</body>
</html>
